home *** CD-ROM | disk | FTP | other *** search
/ Shareware Super Platinum 8 / Shareware Super Platinum 8.iso / mac / MODEMPRO / HOST110.ZIP;1 / HOSTFILE.SCR < prev    next >
Encoding:
Text File  |  1994-05-14  |  6.3 KB  |  223 lines

  1. ' File area routines for host mode.
  2. '
  3. ' DO NOT COMPILE THIS FILE BY ITSELF!
  4. '
  5. ' This file is a part of the complete HOST.SCR and will not compile
  6. ' alone.  To recompile the host scripts, select Scripts/Compile from
  7. ' the QmodemPro for Windows menu and select HOST.SCR in the "Compile
  8. ' script" dialog box.  This file will automatically be compiled as
  9. ' part of the full script.
  10.  
  11. function GetProtocol as integer
  12.   dim s as string
  13.   if not DisplayFile(ProtocolFileName) then
  14.     send #Port, "Select a file transfer protocol:"
  15.     send #Port,
  16.     send #Port, "[A] Ascii  [X] Xmodem   [C] Xmodem/CRC  [1] Xmodem/1K  [F] Xmodem/1KG"
  17.     send #Port, "[Y] Ymodem [G] Ymodem/G [Z] Zmodem      [K] Kermit"
  18.   end if
  19.   send #Port,
  20.   send #Port, "Current directory is:"
  21.   send #Port, curdir
  22.   s = GetLine("Protocol: ")
  23.   select case OemUpper(left(s, 1))
  24.     case "A"
  25.       GetProtocol = ASCII
  26.     case "X"
  27.       GetProtocol = Xmodem
  28.     case "C"
  29.       GetProtocol = XmodemCRC
  30.     case "1"
  31.       GetProtocol = Xmodem1K
  32.     case "F"
  33.       GetProtocol = Xmodem1KG
  34.     case "Y"
  35.       GetProtocol = Ymodem
  36.     case "G"
  37.       GetProtocol = YmodemG
  38.     case "Z"
  39.       GetProtocol = Zmodem
  40.     case "K"
  41.       GetProtocol = Kermit
  42.   end select
  43. end function
  44.  
  45. function ProtocolName(prot as integer) as string
  46.   select case prot
  47.     case ASCII
  48.       ProtocolName = "ASCII"
  49.     case Xmodem
  50.       ProtocolName = "Xmodem"
  51.     case XmodemCRC
  52.       ProtocolName = "Xmodem/CRC"
  53.     case Xmodem1K
  54.       ProtocolName = "Xmodem/1K"
  55.     case Xmodem1KG
  56.       ProtocolName = "Xmodem/1KG"
  57.     case Ymodem
  58.       ProtocolName = "Ymodem"
  59.     case YmodemG
  60.       ProtocolName = "Ymodem/G"
  61.     case Zmodem
  62.       ProtocolName = "Zmodem"
  63.     case Kermit
  64.       ProtocolName = "Kermit"
  65.   end select
  66. end function
  67.  
  68. ' List files
  69.  
  70. sub ListFiles
  71.   dim result as integer, count as integer, total as integer, sr as SearchRec
  72.   if Setup.dlpath = "" then
  73.     send #Port,
  74.     send #Port, "Sorry, downloads are not available."
  75.     send #Port,
  76.     exit sub
  77.   end if
  78.   total = 0
  79.   count = 0
  80.   result = FindFirst(AddBackSlash(curdir)+"*.*", 0, sr)
  81.   do while result = 0 and not CallerHungUp
  82.     dim i as integer
  83.     i = instr(sr.name, ".")
  84.     if i > 0 then
  85.       send #Port, left(sr.name, i-1); tab(10); right(sr.name, len(sr.name)-i); tab(14);
  86.     else
  87.       send #Port, sr.name; tab(14);
  88.     end if
  89.     send #Port, space(11-len(str(sr.size))); sr.size;
  90.     send #Port, DateToDateString(" mm-dd-yy", DMYtoDate(sr.date and 0x1f, (sr.date\32) and 0xf, 1980+(sr.date\512)));
  91.     dim t as long
  92.     t = sr.time
  93.     if t < 0 then
  94.       t = t + 65536
  95.     end if
  96.     send #Port, TimeToTimeString(" HH:mmt", HMStoTime(t\2048, (t\32) and 0x3f, (t and 0x1f) * 2));
  97.     send #Port,
  98.     total = total + 1
  99.     count = count + 1
  100.     if count >= 24 then
  101.       if OemUpper(GetLine("-Pause- [C]ontinue, [S]top? ", 1)) = "S" then
  102.         exit do
  103.       end if
  104.       count = 0
  105.     end if
  106.     result = FindNext(sr)
  107.   loop
  108.   send #Port,
  109.   send #Port, total; " file(s) available in"
  110.   send #Port, curdir
  111.   send #Port,
  112.   GetLine "Press Enter to continue? "
  113. end sub
  114.  
  115. ' Download file
  116.  
  117. sub DownloadFile
  118.   dim fnames as string, protocol as integer, count as integer
  119.   dim onefile as integer
  120.   if Setup.dlpath = "" then
  121.     send #Port,
  122.     send #Port, "Sorry, downloads are not available."
  123.     send #Port,
  124.     exit sub
  125.   end if
  126.   protocol = GetProtocol()
  127.   if protocol = 0 then exit sub
  128.   onefile = protocol < Ymodem
  129.   do
  130.     dim s as string
  131.     s = GetLine("File to download: ")
  132.     if CallerHungUp then
  133.       exit sub
  134.     end if
  135.     if s = "" then exit do
  136.     send #Port,
  137.     if Setup.sysopanypath = 0 or User.Level = 0 then
  138.       s = AddBackSlash(curdir)+JustFilename(s)
  139.     elseif instr(s, "\") = 0 then
  140.       s = AddBackSlash(curdir)+JustFilename(s)
  141.     end if
  142.     dim sr as SearchRec
  143.     if findfirst(s, 0, sr) = 0 then
  144.       do
  145.         if len(fnames) > 0 then
  146.           fnames = fnames + " "
  147.         end if
  148.         fnames = fnames + AddBackSlash(JustPathName(s)) + sr.Name
  149.         count = count + 1
  150.         dim i as integer
  151.         i = instr(sr.name, ".")
  152.         if i > 0 then
  153.           send #Port, left(sr.name, i-1); tab(10); right(sr.name, len(sr.name)-i); tab(14);
  154.         else
  155.           send #Port, sr.name; tab(14);
  156.         end if
  157.         send #Port, space(11-len(str(sr.size))); sr.size;
  158.         send #Port, DateToDateString(" mm-dd-yy", DMYtoDate(sr.date and 0x1f, (sr.date\32) and 0xf, 1980+(sr.date\512)));
  159.         send #Port, TimeToTimeString(" HH:mmt", HMStoTime(sr.time\2048, (sr.time\32) and 0x3f, (sr.time and 0x1f) * 2));
  160.         send #Port,
  161.       loop until (onefile and count = 1) or findnext(sr) <> 0
  162.       send #Port,
  163.     else
  164.       send #Port, "The file "; s; " could not be found on disk."
  165.     end if
  166.   loop until onefile and count = 1
  167.   if count > 0 then
  168.     if Local then
  169.       send #Port, "The following files would be transferred if you were not on locally:"
  170.       send #Port, fnames
  171.     else
  172.       send #Port,
  173.       send #Port, "Begin your "; ProtocolName(protocol); " download of ";
  174.       if count = 1 then
  175.         send #Port, fnames;
  176.       else
  177.         send #Port, count, " files"
  178.       end if
  179.       send #Port, " now"
  180.       delay 1
  181.       sendfile fnames, protocol
  182.     end if
  183.   else
  184.     send #Port, "No files selected."
  185.   end if
  186. end sub
  187.  
  188. ' Upload file
  189.  
  190. sub UploadFile
  191.   dim fname as string, protocol as integer
  192.   if Setup.ulpath = "" then
  193.     send #Port,
  194.     send #Port, "Sorry, uploads are not available."
  195.     send #Port,
  196.     exit sub
  197.   end if
  198.   if Local then
  199.     send #Port, "Uploads not available when logged on locally"
  200.     exit sub
  201.   end if
  202.   protocol = GetProtocol()
  203.   if protocol = 0 or CallerHungUp then exit sub
  204.   send #Port,
  205.   fname = "your file"
  206.   if protocol < Ymodem then
  207.     fname = GetLine("File to upload: ")
  208.     send #Port,
  209.     if fname = "" or CallerHungUp then exit sub
  210.     fname = AddBackSlash(Setup.ulpath)+JustFilename(fname)
  211.     if exists(fname) then
  212.       send #Port, "The file "; fname; " already exists on disk."
  213.       exit sub
  214.     end if
  215.     send #Port, "Begin your "; ProtocolName(protocol); " upload of "; fname; " now"
  216.   else
  217.     fname = Setup.ulpath
  218.     send #Port, "Begin your "; ProtocolName(protocol); " upload of your file now"
  219.   end if
  220.   delay 1
  221.   receivefile fname, protocol
  222. end sub
  223.